package org.xteam.box2text;

public class TextStruct {

	private Text text;
	private Point point;

	public TextStruct(Text text, Point point) {
		this.text = text;
		this.point = point;
	}

	public Text text() {
		return text;
	}
	
	public Point point() {
		return point;
	}
	
	public int x() {
		return point.x();
	}

	public int y() {
		return point.y();
	}

	public TextStruct alignLeft(Frame f) {
		Text t = text.alignLeft(f.getRightMargin());
        return new TextStruct(t, new Point(f.getRightMargin(), y()));
	}

	public TextStruct alignRight(Frame f) {
		Text t = text.alignRight(f.getRightMargin());
        return new TextStruct(t, new Point(f.getRightMargin(), y()));
	}

	public TextStruct alignCenter(Frame f) {
		Text t = text.alignCenter(f.getRightMargin());
        return new TextStruct(t, new Point(f.getRightMargin(), y()));
	}

	public TextStruct concat(TextStruct textStruct, Frame frame) {
		if (y() == frame.y()) {
			Text Text3 = text().addToLastLine(new Line(frame.x() - x()));
			return new TextStruct(Text3.indentConcat(textStruct.text()),
				new Point(x() + textStruct.x() + (frame.x() - x()) , frame.y() + textStruct.y()));
		}
		return new TextStruct(text().startNewLine(), new Point(0, y() + 1)).concat(textStruct, frame);

		///*Text3 && (X4,Y4)*/ TextStruct ts = concat ( Text1 && (X1,Y1), Text2 && (X2,Y2) ) with (X3,Y3) & Defs;
		//concat ( Text1 Texts1 && (X1,Y1), Text2 && (X2,Y2) ) with (X3,Y3) & Defs =
		//return Text3 Texts1 && (X3,Y3);
	}

}
